import request from '@/utils/request';
import { getPageSize } from '@/utils/common';
import { stringify } from 'qs';

// 一、杂费
// 1、查询杂费列表
export async function selectIncidentalList(params) {
  params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/tms/tms-miscellaneous/selectList`, {
    method: 'POST',
    body: params,
  });
}

// 2、查询杂费详情
export async function selectIncidentalDetail(params) {
  return request(`/server/api/tms/tms-miscellaneous/selectDetails`, {
    method: 'POST',
    body: params,
  });
}

//3、新增、编辑--杂费
export async function incidentalOperate(params) {
  let url = '';
  if (params.id) {
    url = 'updateMiscellaneous';
  } else {
    url = 'insertMiscellaneous';
  }
  return request(`/server/api/tms/tms-miscellaneous/${url}`, {
    method: 'POST',
    body: params,
  });
}

// 4、杂费 删除
export async function removeIncidental(params) {

  return request(`/server/api/tms/tms-miscellaneous/deleteMiscellaneous`, {
    method: 'POST',
    body: params,
  });
}

// 5、杂费 生成账单
export async function generatedBills(params) {
  return request(`/server/api/tms/tms-miscellaneous/generateBill`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 查询附件
 */
export async function selectFileList(params) {
  return request(`/server/api/tms/attachment/selectFileList`, {
    method: 'POST',
    body: params,
  });
}

export async function selectAll(params) {
  return request(`/server/api/tms/tms-miscellaneous/generateBillByCheckAll`, {
    method: 'POST',
    body: params,
  });
}



//加入账单 确认按钮  POST /tms-miscellaneous/joinBill
export async function addBillConfirm(params) {
  return request(`/server/api/tms/tms-miscellaneous/joinBill`, {
    method: 'POST',
    body: params,
  });
}
//杂费确认按钮   tms-miscellaneous/confirmMiscellaneous
export async function incidentConfirm(params) {
  return request(`/server/api/tms/tms-miscellaneous/confirmMiscellaneous`, {
    method: 'POST',
    body: params,
  });
}
//导出 
export async function InfoDownload(params) { 
  
  params.token = localStorage.getItem('token');
  const url = `/server/api/tms/tms-miscellaneous/exportMiscellaneous?${stringify(params)}`;
  window.open(url);
}